package twentytwenty;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2020-12-07 13:25
 * @Modified By:
 */
public class HammingWeight_191 {
    public static void main(String[] args) {
        int n = 11;
        System.out.println(hammingWeight(n));
    }

    public static int hammingWeight(int n) {
        int result = 0;
        int fuck = 1;
        for (int i = 0; i < 32; i++) {
            if ((n & fuck) != 0){
                result ++;
            }
            n >>= 1;
        }
        return result;
    }
}
